package net.zoneland.knowledge.service.impl;

import net.zoneland.knowledge.dao.PopupPromptMapper;
import net.zoneland.knowledge.model.PopupPrompt;
import net.zoneland.knowledge.model.PopupPromptLog;
import net.zoneland.knowledge.service.PopupPromptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class PopupPromptServiceImpl implements PopupPromptService {

    @Autowired
    private PopupPromptMapper popupPromptMapper;

    /**
     * 根据用户id查新功能id
     * @param userId 用户id
     * @return
     */
    @Override
    public List<PopupPromptLog> findPopupPromptLogByUserId(final String userId) {
        return popupPromptMapper.findPopupPromptLogByUserId(userId);
    }

    /**
     * 添加信息到日志表
     * @param userId 用户id
     * @param userName 用户名称
     * @param newFunctionId 新功能提醒id
     */
    @Override
    public void addPopupPromptLog(final String userId, final String userName, final String newFunctionId) {
        final String uuid = UUID.randomUUID().toString();
        popupPromptMapper.addPopupPromptLog(uuid, userId, userName, newFunctionId);
    }

    /**
     * 查询功能提醒表当前时间小于失效时间的Id.
     * @return id集合
     */
    @Override
    public List<PopupPrompt> findPopupPromptId() {
        return popupPromptMapper.findPopupPromptId();
    }

    /**
     * 根据id查询内容
     * @param id id
     * @return  离当前时间最近的一条内容.
     */
    @Override
    public PopupPrompt findContentById(final String id) {
        return popupPromptMapper.findContentById(id);
    }
}
